<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结构伪类</title>
    <style type="text/css">
        .outer {
            width: 80%;
            border: 1px solid blue;
            margin: 25px auto;
        }
        
        .outer>* {
            height: 20px;
            border: 1px solid green;
            margin: 10px;
        }
        
        .wrapper:first-child {
            background: #9696ff;
        }
        
        .wrapper:last-child {
            background: #ffc596;
        }
    </style>

</head>

<body>

    <div class="outer">
        <!-- 匹配 .wrapper:first-child 或 .wrapper:nth-child(1) -->
        <div class="wrapper first">甲子</div>
        <div class="wrapper second">乙丑</div>
        <!-- 匹配 .wrapper:last-child 或 .wrapper:nth-last-child(1) -->
        <div class="wrapper third">丙寅</div>
    </div>

    <div class="outer">
        <!-- 匹配于 .wrapper:first-child 或 .wrapper:nth-child(1) -->
        <p class="wrapper first">丁卯</p>
        <p class="wrapper second">戊辰</p>
        <!-- 匹配 .wrapper:last-child 或 .wrapper:nth-last-child(1) -->
        <p class="wrapper third">辰巳</p>
    </div>

    <hr>

    <div class="outer">
        <!-- .first 元素不能匹配于 .wrapper:first-child 和 .wrapper:nth-child(1) -->
        <div class="first">甲子</div>
        <div class="second wrapper">乙丑</div>
        <!-- .third 元素不能匹配于 .wrapper:last-child 和 .wrapper:nth-last-child(1) -->
        <div class="third">丙寅</div>
    </div>


</body>

</html>